<?php


namespace App\Http\Common\OaFlow;

use App\Http\Common\Base\CCompanySet;
use App\Http\Common\ConfigRoot;
use App\Http\Common\DingTalk\CDingtalkMessager;
use App\Http\Common\WechatWork\CWechatWorkMessager;
use App\Http\Role\REmployee;

class Config extends ConfigRoot
{

    static $mongo_flowformtempsaves='flowformtempsaves';

    static $mongo_flowdesigns='flowdesigns';
    static $mongo_flowlists='flowlists';
    static $mongo_flowlogs='flowlogs';
    static $mongo_flowsmessagetos='flowmessagetos';

    //static $mongo_flowmessageto_mergesaves='flowmessageto_mergesaves';



    static $mongo_flowcancels='flowcancels';
    static $mongo_flowtimeoutlogs='flowtimeoutlogs';

    static $mongo_flowcreatalerts='flowcreatalerts';

    static $mongo_flowpermission='flowpermission';


    static $messageStatus=false;

    static $canSendMessage=true;


    static $CreatAlertInterval=60;


    public static $isTestMode=false;

    public static function getUser()
    {
        return parent::getUser(); // TODO: Change the autogenerated stub
    }




    static $UserReal=null;

    public static function getUserReal(){
        if(!empty(static::$UserReal)){
            return static::$UserReal;
        }
        if(empty(REmployee::$RoleIOReal)){
            static::$UserReal=new REmployee();
        }else{
            static::$UserReal=REmployee::$RoleIOReal;
        }
        return static::$UserReal;
    }

    public static function return_user_info($userid_key=null,$username_key=null){

        if(empty(REmployee::$RoleIOReal)){
            return [];
        }

        $arr=[];

        if(!empty($userid_key)){
            $arr['__'.$userid_key]=REmployee::$RoleIOReal->id;
        }

        if(!empty($username_key)){
            $arr['__'.$username_key]=REmployee::$RoleIOReal->name;
        }
        return $arr;

    }







    static private $Messager=null;

    static public function Messager(){
//            //:REmployee
        //dd(CCompanySet::getSet('UserPlatform','string'));
            if(empty(static::$Messager)){
                switch (CCompanySet::getSet('UserPlatform','string'))
                {
                case 'dingtalk':
                    static::$Messager=CDingtalkMessager::getInstance();
                  break;
                case 'wechatwork':
                    static::$Messager=CWechatWorkMessager::getInstance();
                  break;
                default:
                }
            }
            return static::$Messager;


    }

}